package org.toves.checklua.scan;

public class Token {
	private int line;
	private int column;
	private TokenType type;
	private String text;
	
	public Token(TokenType type, int line, int column, String text) {
		this.type = type;
		this.line = line;
		this.column = column;
		this.text = text;
	}
	
	public int getLine() {
		return line;
	}
	
	public int getColumn() {
		return column;
	}
	
	public TokenType getTokenType() {
		return type;
	}
	
	public String getText() {
		return text;
	}
	
	public String getText(int maxLength) {
		String ret = text;
		if (ret.length() > maxLength) {
			if (maxLength >= 6) {
				return text.substring(0, maxLength - 4) + ".."
					+ text.substring(text.length() - 2);
			} else if (maxLength >= 4) {
				return text.substring(0, maxLength - 2) + "..";
			} else {
				return text.substring(0, maxLength);
			}
		} else {
			return text;
		}
	}
}
